package cc.customer.ServicesUtils;

import cc.customer.expCustomer.domain.ExEmp;
import cc.customer.common.utils.DateUtil;
import cc.customer.common.utils.Utils;
import cc.customer.rabbit.domain.CconvNotice;
import cc.customer.system.domain.MyUser;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * 消息通知类型
 * **/
public class NoticeUtils {

	private static  final Logger logger = LoggerFactory.getLogger(NoticeUtils.class);
	/**推广资源自动分配通知**/
	public static CconvNotice ExempAutoNotice(ExEmp exEmp1,ExEmp exEmp){
		CconvNotice notice = new CconvNotice();
		notice.setcConvTitle("自动分配推广资源客户");
		JSONObject json = new JSONObject();
		json.put("content","分配了1个推广资源客户至您部门");
		json.put("customerid",exEmp1.getcExUuid());
		json.put("customername",exEmp.getcExName());
		json.put("cusid",exEmp1.getcExId());
		json.put("custype","1");
		json.put("ntype","1");
		notice.setcConvCont(json.toJSONString());
		notice.setcConvStatus("0");
		notice.setcConvType("2");
		notice.setcConvNType("5");
		notice.setcConvDept(exEmp.getcExDept());
		notice.setcConvCreator(exEmp.getcExCreator());
		logger.info("自动分配的部门:"+exEmp.getcExDept());
		notice.setcConvDept(exEmp.getcExDept());
		return notice;
	}
	/**推广资源手动分配**/
	public static CconvNotice ExempShouNotice(ExEmp exEmp1,ExEmp exEmp){
		CconvNotice notice = new CconvNotice();
		notice.setcConvTitle("手动分配推广资源客户");
		JSONObject json = new JSONObject();
		json.put("content","分配了1个推广资源客户");
		json.put("customerid",exEmp1.getcExUuid());
		json.put("customername",exEmp.getcExName());
		json.put("cusid",exEmp1.getcExId());
		json.put("custype","1");
		json.put("ntype","1");
		notice.setcConvCreator(exEmp.getcExCreator());
		notice.setcConvCont(json.toJSONString());
		notice.setcConvType("1");
		notice.setcConvNType("5");
		notice.setcConvCreator(exEmp.getcExCreator());
		logger.info("手动分配的客服:"+exEmp.getcExDept());
		return notice;
	}
	/**销售计划通知消息**/
	public static CconvNotice planSaleNotice(String type, MyUser user){
		String typename = "";
		String ntype = "";
		String content = "";
		if("1".equals(type)){
			typename = "定时任务";
			ntype = "7";
			content = "定时任务提醒";
		}else{
			typename = "电话计划";
			ntype = "8";
			content = "电话计划提醒";
		}
		CconvNotice notice = new CconvNotice();
		notice.setcConvType("1");
		notice.setcConvTitle(typename);
		notice.setcConvNType(ntype);
		notice.setcConvCreator(user.getUserUuid());
		notice.setcConvUsers(user.getUsername());
		JSONObject json = new JSONObject();
		json.put("content",content);
		notice.setcConvCont(json.toJSONString());
		return notice;
	}
	/**大资源批量分配**/
	public static CconvNotice bigEmpBatchNotice(String creator, int size, List<String> name,List<String> Uuis,List<String> ods){
		CconvNotice notice = new CconvNotice();
		notice.setcConvType("1");
		notice.setcConvTitle("大资源批量分配客户");
		notice.setcConvNType("5");
		notice.setcConvCreator(creator);
		JSONObject json = new JSONObject();
		json.put("content","分配了"+size+"个大资源客户给您");
		json.put("customername", StringUtils.join(name,","));
		json.put("customerid",StringUtils.join(Uuis,","));
		json.put("cusid",StringUtils.join(ods,","));
		json.put("custype","3");
		json.put("ntype","1");
		notice.setcConvCont(json.toJSONString());
		return notice;
	}

	/**月报推送**/
	public static CconvNotice monthReport(){
		String today = DateUtil.getCurrentDate("yyyy-MM");
		CconvNotice notice = new CconvNotice();
		notice.setcConvSession(Utils.getUUID());
		notice.setcConvTitle(today+"月报");
		notice.setcConvStatus("0");
		notice.setcConvTime(DateUtil.getCurrentDate("yyyy-MM-dd HH:mm:ss"));
		notice.setcConvType("3");
		return notice;
	}

}
